<?php 
## include required files
/*******************************/
require_once '../model/config.php';
/*******************************/

## Create Objects
/*******************************/
$configObj = new Model_Config();
/*******************************/
if(isset($_POST['add_txt'])) {
	## apply PHP validation for required filed
	if(trim($_POST['footer_flag']) != '' ) {
			$array = array();
			$array['config_value'] = return_post_value($_POST['footer_flag']);
			$configObj->editConfigVlaueById($array, base64_decode($_GET['id']));
			$_SESSION['msg'] = "<div class='success_msg'><span>Config value updated successfully. </span></div>";
			header('location:'.SITE_URL.'/admin/home.php?q=defaultsettings&page='.$_GET['page']);
			exit;
			
	} else {// php validation else
		$_SESSION['msg'] = "<div class='error_msg'><span>Please enter new Username and password.</span></div>";
	}
	// main if closed
}

## Assign success or error msg to smarty variable and unset session variable
if(trim($_SESSION['msg']) != '') {
	$smarty->assign('msg', $_SESSION['msg']);
	unset($_SESSION['msg']);
}

## Fetch footer text
if(isset($_GET['id'])) {
	$id = base64_decode($_GET['id']);
	$config = $configObj->getConfigValueById($id);
	$smarty->assign('config', $config);
}

## Set active class variable for left menu (main menu and sub menu)
$smarty->assign('activeclass', 'defaultsettings');
$smarty->assign('mainmenu', '4');

## Unset all the objects created which are on this page
unset($configObj);

$smarty->display(TEMPLATEDIR_ADMIN. 'settings/updateflag.tpl');
unset($smarty);
?>